package Calculation;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-23
 * Time: 8:57
 */
public class Test1{

    public void moveZeroes(int[] nums) {
        int dest = -1;
        int cur = 0;
        int tem = 0;

        while(cur < nums.length){
            if(nums[cur] != 0){
                dest++;
                tem = nums[dest] ;
                nums[dest] = nums[cur];
                nums[cur] = tem;
            }
            cur++;
        }

    }

    public static void main(String[] args) {
        int[] array = new int[]{0,1,12,0};
        Test1 test1 = new Test1();
        test1.moveZeroes(array);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+"  ");
        }

    }
}